import React from 'react';
import { Box, Alert } from '@mui/material';
import InfoSection from './InfoSection';
import InfoItem from './InfoItem';
import { BasicInfo } from '../types';

interface BasicInfoSectionProps {
    basicInfo: BasicInfo | null;
    loading: boolean;
    error: string | null;
    onEdit: () => void;
    onImport?: () => void;
}

const BasicInfoSection: React.FC<BasicInfoSectionProps> = ({ basicInfo, loading, error, onEdit, onImport }) => {
    return (
        <InfoSection title="基础信息" onEdit={onEdit} onImport={onImport} loading={loading}>
            {error && (
                <Alert severity="error" sx={{ mb: 2 }}>
                    {error}
                </Alert>
            )}
            {basicInfo && (
                <Box className="form-grid">
                    <InfoItem label="学号" value={basicInfo.studentId} />
                    <InfoItem label="姓名" value={basicInfo.name} />
                    <InfoItem label="性别" value={basicInfo.gender} />
                    <InfoItem label="书院" value={basicInfo.academy} />
                    <InfoItem label="专业" value={basicInfo.major} />
                    <InfoItem label="年级" value={basicInfo.grade} />
                    <InfoItem label="预毕业学期" value={basicInfo.graduationPreTerm} />
                    <InfoItem label="预毕业年份" value={basicInfo.graduationPreYear} />
                    <InfoItem label="联系方式" value={basicInfo.phone} />
                    <InfoItem label="邮箱" value={basicInfo.email} />
                    <InfoItem label="学籍状态" value={basicInfo.status} />
                    <InfoItem label="CGPA" value={basicInfo.cgpa} />
                    <InfoItem label="修分情况" value={basicInfo.creditStatus} />
                    <InfoItem label="招生类型" value={basicInfo.enrollmentType} />
                    <InfoItem label="预警信息" value={basicInfo.warnInfo} />
                    <InfoItem label="顾问" value={basicInfo.advisor} />
                </Box>
            )}
        </InfoSection>
    );
};

export default BasicInfoSection;
